// 每天一遍快排，烂熟于心
function quickSort(arr, l, r) {
    let head = l, tail = r, key = arr[head]
    while(head < tail) {
        while(head < tail && arr[tail] > key) {
            tail--
        }
        arr[head] = arr[tail]
        while(head < tail && arr[head] < key) {
            head++
        }
        arr[tail] = arr[head]
    }
    arr[head] = key
    if(head > l) {
        quickSort(arr, l, head - 1)
    }
    if(head + 1 < r) {
        quickSort(arr, head + 1, r)
    }
}
let arr = [6, 7, 3, 4, 1, 5]
quickSort(arr, 0, arr.length - 1)
console.log(arr);